using UnityEngine;
using System.Collections;

public class EscapeHandler {

    private static EscapeHandler instance = null;

    private EscapeHandler()
    {
        MessageBoxShowing = false;
        Owner = string.Empty;
    }

    public static EscapeHandler Instance
    {
        get
        {
            if (instance == null)
                instance = new EscapeHandler();
            return instance;
        }
    }

    public string Owner { get; private set; }

    public bool TryExecute(string owner)
    {
        if (owner == "msgbox" && !MessageBoxShowing) return false;
        if (owner == "game" && MessageBoxShowing) return false;


        if (string.IsNullOrEmpty(Owner))
        {
            this.Owner = owner;
        }

        if (this.Owner == owner)
            return true;
        return false;
        
    }

    public void Reset()
    {
        Owner = string.Empty;
        MessageBoxDestroyed = false;
    }

    public bool MessageBoxShowing { get; set; }
    public bool MessageBoxDestroyed { get; set; }

}
